<template>
  <div>
    <!-- 经销商名称\代码搜索 -->
    <TopFilter
      :list="topFilterInit"
      :cols="3"
      :collapse="collapse"
      labelWidth="90"
      @filterChange="changeHandle"
    ></TopFilter>
    <!-- table -->
    <FilterTable
      height="250"
      ref="listModal"
      :columns="columns"
      :selectionType="selectType"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="selectChange"
    ></FilterTable>
    <div class="dialogBottmView" :style="{position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'}">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">确定</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getDealerList ,getDealerInfos} from '@/api/admin/notice/dcsNoticeMaintain/dealerdata';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    },
    selectType:{
      type: String,
      default: 'multiple'
    }
  },
  data() {
    return {
      excludeBigCustomer:this.value.excludeBigCustomer ? 25031004 : null,
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchApi:getDealerInfos,
      fetchParams: {
       /*  excludeBigCustomer: this.value.excludeBigCustomer ? 25031004 : null,
        isDeleted: 0 */
      }, //ipa 接口
      selectedRows: []//选中经销商
    };
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: '所属区域', fieldName: 'dealerCode', placeholder: '请输入', initialValue: '' },
        { type: 'INPUT', label: '经销商名称', fieldName: 'dealerName', placeholder: '请输入', initialValue: '' }
      ];
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({},val);
      this.fetchParams.excludeBigCustomer = this.excludeBigCustomer;
      this.fetchParams.isDeleted = 0;
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '所属区域', dataIndex: 'saleArea', sorter: true },
        { title: '经销商名称', dataIndex: 'dealerName', sorter: true },
        // { title: '经销商代码', dataIndex: 'dealerCode', sorter: true },
        // { title: '经销商简称', dataIndex: 'dealerShortname', sorter: true },
        // { title: '经销商类型', dataIndex: 'dealerType', sorter: true, render: props => {
        //     return <span>{this.createDictText(props.row.dealerType, '2503')}</span>;
        //   } },
        // { title: '经销商级别', dataIndex: 'field4', sorter: true },
        // { title: '事业部', dataIndex: 'field5', sorter: true },
        // { title: '省份', dataIndex: 'provinceId', sorter: true , render: props => {
        //     return <span>{this.createDictText(props.row.provinceId, '1056')}</span>;
        //   }},
        // { title: '城市', dataIndex: 'cityId', sorter: true ,render: props => {
        //     return <span>{this.createDictText(props.row.cityId, '1056')}</span>;
        //   }},
        // { title: '县区', dataIndex: 'countyId', sorter: true ,render: props => {
        //     return <span>{this.createDictText(props.row.countyId, '1056')}</span>;
        //   }}
      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      console.log("excludeBigCustomer:"+this.excludeBigCustomer);
      this.$emit('close', { visible: false ,"data":this.selectedRows});
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false ,"data":this.selectedRows});
    }
  },
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped>
</style>
